using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_changepassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
    }

    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            MailProvider mailProvider = new MailProvider();
            RecruitVietnam cls = new RecruitVietnam();
            cls.ConnectionString = 
            WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
            string jsemail = Convert.ToString(Session["jsemail"]);
            if (jsemail == "")
                Response.Redirect("login.aspx");
            if (cls.ChangePassword(jsemail, 
            txtOldPassword.Text, txtPassword.Text, "0"))
            {
                literalError.Text = 
                "You have changed password successful."
                +"<br>It will be effected on next time";

                mailProvider.SendMail(jsemail,
                "Changed Password", "Your password "+
                "have been changed.<br>Thanks you for" +
                " using RecruitVietnam.com service.");                 
                btnOK.PostBackUrl = "myaccount.aspx"; 
            }
            else
            {
                literalError.Text = 
                "Sorry, your password is not correct."
                + cls.ErrorMessage;
                 
            }
        }
        catch(Exception ex)
        {
            literalError.Text = ex.Message;
        }
    }
}
